package org.sean.framework.kafka.logging.encoding;

import ch.qos.logback.core.Layout;

/**
 * A KafkaMessageEncoder that can be configured with a {@link Layout} and creates
 * a serialized string for each event using the given layout.
 *
 * @param <E> E
 */
public class LayoutKafkaMessageEncoder<E> extends BaseKafkaMessageEncoder<E> {

    private Layout<E> layout;

    public LayoutKafkaMessageEncoder() {
    }

    public LayoutKafkaMessageEncoder(Layout<E> layout) {
        this.layout = layout;
    }

    @Override
    public String doEncode(E event) {
        return layout.doLayout(event);
    }

    public Layout<E> getLayout() {
        return layout;
    }

    public void setLayout(Layout<E> layout) {
        this.layout = layout;
    }

}
